package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 互动提问的问题表 控制器
 * </p>
 *
 * @author xjs
 */
@Api(tags = "InteractionQuestion管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/questions")
public class InteractionQuestionController {

    private final IInteractionQuestionService interactionQuestionService;

    /**
     * 新增提问
     * */
    @ApiOperation("新增提问")
    @PostMapping
    public void addQuestion(@Valid @RequestBody QuestionFormDTO dto){
        interactionQuestionService.addQuestion(dto);
    }

    /**
     * 问题分页查询
     * */
    @ApiOperation("问题分页查询")
    @GetMapping("/page")
    public PageDTO<QuestionVO> pageQuery(QuestionPageQuery query){
        return interactionQuestionService.pageQuery(query);
    }

    @ApiOperation("问题详情")
    @GetMapping("/{id}")
    public QuestionVO details(@PathVariable("id") Long id){
        return interactionQuestionService.details(id);
    }




}
